/**      
 * @file		strcmp.cpp
 * @description	This examples demonstrates how to compare two
 *				cStrings. We can't use > < <= etc. We have to use
 *				strcmp() function from the cstring library.
 * @course		CSCI 123 Section 00000
 * @assignment 
 * @date		mm/dd/yyyy
 * @author		Brad Rippe (00000000) brippe@fullcoll.edu
 * @version		1.0
 */
#include <iostream>
#include <cstring>
using namespace std;

/**
 * @return zero if the application executes successfully
 */
int main() {
	char cString1[] = "Please email my message to the class!";
	char cString2[50] = "";

	cout << "cString1 = " << cString1 << endl;
	cout << "cString2 = " << cString2 << endl;	
	// strcmp compares strings lexicographically
	// returns 
	// < 0 string1 less than string2
	// 0 string1 identical to string2
	// > 0 string1 greater than string2
	cout << "Using == \n";
	if(cString1 == cString2) {
		cout << "string 1 is equal to string 2\n";
	} else {
		cout << "string 1 is not equal to string 2\n";
	}

	cout << "Using strcmp()\n";
	if(strcmp(cString1, cString2) < 0) {
		cout << "string 1 is less than string 2\n";
	} else if(strcmp(cString1, cString2) == 0) {
		cout << "string 1 equal to string 2\n";
	} else if(strcmp(cString1, cString2) > 0) {
		cout << "string 1 is greater than string 2\n";
	}

	strncpy(cString2, cString1, 38);
	cout << "cString1 = " << cString1 << endl;
	cout << "cString2 = " << cString2 << endl;	
	cout << "Using == \n";
	if(cString1 == cString2) {
		cout << "string 1 is equal to string 2\n";
	} else {
		cout << "string 1 is not equal to string 2\n";
	}
	
	cout << "Using strcmp()\n";
	if(strcmp(cString1, cString2) < 0) {
		cout << "string 1 is less than string 2\n";
	} else if(strcmp(cString1, cString2) == 0) {
		cout << "string 1 equal to string 2\n";
	} else if(strcmp(cString1, cString2) > 0) {
		cout << "string 1 is greater than string 2\n";
	}
	return 0;
}

